/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pl.project.engineering.logger;

import java.io.File;
import lombok.extern.slf4j.Slf4j;
import org.apache.log4j.DailyRollingFileAppender;
import org.apache.log4j.Logger;
import org.apache.log4j.PatternLayout;

/**
 *
 * @author ikrzysiek
 */
@Slf4j
public class RollingFileAppenderCreator {

  public void createRolingFileAppender(String applicationJarDir) {
    DailyRollingFileAppender fa = new DailyRollingFileAppender();
    fa.setName("fileLogger");
    fa.setFile(applicationJarDir + File.separator + "logs" + File.separator + "app.log");
    fa.setLayout(new PatternLayout("%d{dd-MM-yy HH:mm:ss:SSS} - {%p} %c{2} Thread [%t]; %x %m%n"));
    fa.setAppend(true);
    fa.setDatePattern("'.'yyyy-MM-dd");
    fa.activateOptions();
    Logger.getRootLogger().addAppender(fa);
  }
}
